find_pid=`netstat -atpn | grep LISTEN | grep -E '8809' | grep '/java' | awk '{print $7}' | awk -F '/' '{print $1}'`

if test ! -z $find_pid; then
    echo "old process id: " $find_pid
    kill -9 $find_pid
    echo "old process stopped"
fi
echo "start serivce..."
nohup java -jar haydn-delivercore-agent-1.0.0.jar >./haydn-delivercore-agent.log 2>&1 &
sleep 1
tail -f ./haydn-delivercore-agent.log

for _ in 1 2 3 4
do
    if test ! -z $find_pid; then
        echo "new process id:" $find_pid
        echo "service OK"
	exit 1
    fi
done